home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickTime / QuickTime 3 Interfaces & Libs / QTDevWin / CIncludes / DeskBus.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  9.1 KB  |  221 lines  |  [TEXT/dosa]

  1. /*
  2.      File:        DeskBus.h
  3.  
  4.      Contains:    Apple Desktop Bus (ADB) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 3.0
  8.  
  9.      Copyright:    © 1987-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __DESKBUS__
  19. #define __DESKBUS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28.  
  29.  
  30. #if PRAGMA_ONCE
  31. #pragma once
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if PRAGMA_IMPORT
  39. #pragma import on
  40. #endif
  41.  
  42. #if PRAGMA_STRUCT_ALIGN
  43.     #pragma options align=mac68k
  44. #elif PRAGMA_STRUCT_PACKPUSH
  45.     #pragma pack(push, 2)
  46. #elif PRAGMA_STRUCT_PACK
  47.     #pragma pack(2)
  48. #endif
  49.  
  50. #if TARGET_OS_MAC
  51. typedef SInt8                             ADBAddress;
  52. typedef CALLBACK_API( void , ADBCompletionProcPtr )(Ptr buffer, Ptr refCon, long command);
  53. /*
  54.     WARNING: ADBCompletionProcPtr uses register based parameters under classic 68k
  55.              and cannot be written in a high-level language without 
  56.              the help of mixed mode or assembly glue.
  57. */
  58. typedef CALLBACK_API( void , ADBDeviceDriverProcPtr )(SInt8 devAddress, SInt8 devType);
  59. /*
  60.     WARNING: ADBDeviceDriverProcPtr uses register based parameters under classic 68k
  61.              and cannot be written in a high-level language without 
  62.              the help of mixed mode or assembly glue.
  63. */
  64. /*
  65.     TempADBServiceRoutineUPP is needed because of circular definition of
  66.     ADBServiceRoutineProcPtr and ADBServiceRoutineUpp depending on each other.
  67. */
  68. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             TempADBServiceRoutineUPP;
  69. typedef CALLBACK_API( void , ADBServiceRoutineProcPtr )(Ptr buffer, TempADBServiceRoutineUPP completionProc, Ptr refCon, long command);
  70. /*
  71.     WARNING: ADBServiceRoutineProcPtr uses register based parameters under classic 68k
  72.              and cannot be written in a high-level language without 
  73.              the help of mixed mode or assembly glue.
  74. */
  75. typedef REGISTER_UPP_TYPE(ADBCompletionProcPtr)                 ADBCompletionUPP;
  76. typedef REGISTER_UPP_TYPE(ADBDeviceDriverProcPtr)                 ADBDeviceDriverUPP;
  77. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             ADBServiceRoutineUPP;
  78. typedef CALLBACK_API( void , ADBInitProcPtr )(SInt8 callOrder);
  79. /*
  80.     WARNING: ADBInitProcPtr uses register based parameters under classic 68k
  81.              and cannot be written in a high-level language without 
  82.              the help of mixed mode or assembly glue.
  83. */
  84. typedef REGISTER_UPP_TYPE(ADBInitProcPtr)                         ADBInitUPP;
  85.  
  86. struct ADBDataBlock {
  87.     SInt8                             devType;                    /* original handler ID */
  88.     SInt8                             origADBAddr;                /* original ADB Address */
  89.     ADBServiceRoutineUPP             dbServiceRtPtr;                /* service routine pointer */
  90.     Ptr                             dbDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  91. };
  92. typedef struct ADBDataBlock                ADBDataBlock;
  93.  
  94. typedef ADBDataBlock *                    ADBDBlkPtr;
  95.  
  96. struct ADBSetInfoBlock {
  97.     ADBServiceRoutineUPP             siService;                    /* service routine pointer */
  98.     Ptr                             siDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  99. };
  100. typedef struct ADBSetInfoBlock            ADBSetInfoBlock;
  101.  
  102. typedef ADBSetInfoBlock *                ADBSInfoPtr;
  103. /* ADBOpBlock is only used when calling ADBOp from 68k assembly code */
  104.  
  105. struct ADBOpBlock {
  106.     Ptr                             dataBuffPtr;                /* buffer: pointer to variable length data buffer */
  107.     ADBServiceRoutineUPP             opServiceRtPtr;                /* completionProc: completion routine pointer */
  108.     Ptr                             opDataAreaPtr;                /* refCon: this field is passed as the refCon parameter to the completion routine */
  109. };
  110. typedef struct ADBOpBlock                ADBOpBlock;
  111.  
  112. typedef ADBOpBlock *                    ADBOpBPtr;
  113. EXTERN_API( void )
  114. ADBReInit                        (void)                                                        ONEWORDINLINE(0xA07B);
  115.  
  116. /*
  117.     ADBOp has a different interface for 68k assembly than for everything else
  118.     for 68k assembly the interface is 
  119.     #pragma parameter __D0 ADBOp(__A0,__D0)
  120.     OSErr ADBOp( ADBOpBlock * pb, short commandNum );
  121. */
  122. /*
  123.     IMPORTANT NOTE:
  124.     "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
  125.     four parameters using 68k register based calling conventions, specifically the completion routine
  126.     passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
  127.     to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
  128.     to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
  129.     the mistake cannot be corrected.
  130.     The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
  131.     argument which is a pointer to itself, fortunately not needed for PowerPC code.
  132.     For compatibility with existing 68k code, when an ADBOp completion routine is called,
  133.     68k register A1 will point to the completion routine, as documented in Inside Mac.
  134. */
  135. EXTERN_API( OSErr )
  136. ADBOp                            (Ptr                     refCon,
  137.                                  ADBCompletionUPP         compRout,
  138.                                  Ptr                     buffer,
  139.                                  short                     commandNum);
  140.  
  141.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  142.                                                                                             #pragma parameter __D0 CountADBs
  143.                                                                                             #endif
  144. EXTERN_API( short )
  145. CountADBs                        (void)                                                        ONEWORDINLINE(0xA077);
  146.  
  147.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  148.                                                                                             #pragma parameter __D0 GetIndADB(__A0, __D0)
  149.                                                                                             #endif
  150. EXTERN_API( ADBAddress )
  151. GetIndADB                        (ADBDataBlock *            info,
  152.                                  short                     devTableIndex)                        ONEWORDINLINE(0xA078);
  153.  
  154.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  155.                                                                                             #pragma parameter __D0 GetADBInfo(__A0, __D0)
  156.                                                                                             #endif
  157. EXTERN_API( OSErr )
  158. GetADBInfo                        (ADBDataBlock *            info,
  159.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA079);
  160.  
  161.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  162.                                                                                             #pragma parameter __D0 SetADBInfo(__A0, __D0)
  163.                                                                                             #endif
  164. EXTERN_API( OSErr )
  165. SetADBInfo                        (const ADBSetInfoBlock * info,
  166.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA07A);
  167.  
  168. enum { uppADBCompletionProcInfo = 0x007B9802 };                 /* register no_return_value Func(4_bytes:A0, 4_bytes:A2, 4_bytes:D0) */
  169. enum { uppADBDeviceDriverProcInfo = 0x00050802 };                 /* register no_return_value Func(1_byte:D0, 1_byte:D1) */
  170. enum { uppADBServiceRoutineProcInfo = 0x0F779802 };             /* register no_return_value Func(4_bytes:A0, 4_bytes:A1, 4_bytes:A2, 4_bytes:D0) */
  171. enum { uppADBInitProcInfo = 0x00000802 };                         /* register no_return_value Func(1_byte:D0) */
  172. #define NewADBCompletionProc(userRoutine)                         (ADBCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBCompletionProcInfo, GetCurrentArchitecture())
  173. #define NewADBDeviceDriverProc(userRoutine)                     (ADBDeviceDriverUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBDeviceDriverProcInfo, GetCurrentArchitecture())
  174. #define NewADBServiceRoutineProc(userRoutine)                     (ADBServiceRoutineUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBServiceRoutineProcInfo, GetCurrentArchitecture())
  175. #define NewADBInitProc(userRoutine)                             (ADBInitUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBInitProcInfo, GetCurrentArchitecture())
  176. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  177.     /* CallADBCompletionProc can't be called from classic 68k without glue code */
  178. #else
  179.     #define CallADBCompletionProc(userRoutine, buffer, refCon, command)  CALL_THREE_PARAMETER_UPP((userRoutine), uppADBCompletionProcInfo, (buffer), (refCon), (command))
  180. #endif
  181. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  182.     #pragma parameter CallADBDeviceDriverProc(__A0, __D0, __D1)
  183.     void CallADBDeviceDriverProc(ADBDeviceDriverUPP routine, SInt8 devAddress, SInt8 devType) = 0x4E90;
  184. #else
  185.     #define CallADBDeviceDriverProc(userRoutine, devAddress, devType)  CALL_TWO_PARAMETER_UPP((userRoutine), uppADBDeviceDriverProcInfo, (devAddress), (devType))
  186. #endif
  187. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  188.     /* CallADBServiceRoutineProc can't be called from classic 68k without glue code */
  189. #else
  190.     #define CallADBServiceRoutineProc(userRoutine, buffer, completionProc, refCon, command)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppADBServiceRoutineProcInfo, (buffer), (completionProc), (refCon), (command))
  191. #endif
  192. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  193.     #pragma parameter CallADBInitProc(__A0, __D0)
  194.     void CallADBInitProc(ADBInitUPP routine, SInt8 callOrder) = 0x4E90;
  195. #else
  196.     #define CallADBInitProc(userRoutine, callOrder)             CALL_ONE_PARAMETER_UPP((userRoutine), uppADBInitProcInfo, (callOrder))
  197. #endif
  198. #endif  /* TARGET_OS_MAC */
  199.  
  200.  
  201. #if PRAGMA_STRUCT_ALIGN
  202.     #pragma options align=reset
  203. #elif PRAGMA_STRUCT_PACKPUSH
  204.     #pragma pack(pop)
  205. #elif PRAGMA_STRUCT_PACK
  206.     #pragma pack()
  207. #endif
  208.  
  209. #ifdef PRAGMA_IMPORT_OFF
  210. #pragma import off
  211. #elif PRAGMA_IMPORT
  212. #pragma import reset
  213. #endif
  214.  
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218.  
  219. #endif /* __DESKBUS__ */
  220.  
  221.